package com.ipt.frm.hola;

import static org.junit.Assert.assertTrue;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.sun.jersey.test.framework.JerseyTest;

public class SimpleTest extends JerseyTest {
	private static final String RUTA_APLICACION = "http://localhost:8080/PruebaRestfullSM/";
	private static final String RUTA_SERVLET = "rest/hello";
	Client restClient;
	WebTarget target;
	WebTarget resourceTarget;

	@Before
	public void inicializar() {
		restClient = ClientBuilder.newClient();
		target = restClient.target("http://localhost:8080/PruebaRestfullSM/");
	}

	@Test(expected = NoClassDefFoundError.class)
	public void test1() {
		resourceTarget = target.path("rest/hello/");

		String responseStringText = resourceTarget
				.request(MediaType.TEXT_PLAIN).get(String.class);
		assertTrue("Correcto",
				"Hello Jersey".equalsIgnoreCase(responseStringText));
		// System.out.println("Here is the response in PlainText: "
		// + responseStringText);
	}

	@After
	public void destruir() {
		restClient = null;
		target = null;
		resourceTarget = null;
	}
	/*
	 * @Path("hello") public static class HelloResource {
	 * 
	 * @GET public String getHello() { return "Hello World!"; } }
	 * 
	 * @Override protected Application configure() { return new
	 * ResourceConfig(HelloResource.class); }
	 * 
	 * @Test public void test() { final String hello =
	 * target("hello").request().get(String.class); assertEquals("Hello World!",
	 * hello); }
	 */

}